home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / prntcb / printcb.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-05-08  |  6.2 KB  |  199 lines

  1. VERSION 2.00
  2. Begin Form PrintCB 
  3.    BorderStyle     =   3  'Fixed Double
  4.    Caption         =   "Print Clipboard"
  5.    ClientHeight    =   4860
  6.    ClientLeft      =   1620
  7.    ClientTop       =   540
  8.    ClientWidth     =   5220
  9.    Height          =   5265
  10.    Icon            =   PRINTCB.FRX:0000
  11.    Left            =   1560
  12.    LinkMode        =   1  'Source
  13.    LinkTopic       =   "Form2"
  14.    MaxButton       =   0   'False
  15.    ScaleHeight     =   4860
  16.    ScaleWidth      =   5220
  17.    Top             =   195
  18.    Width           =   5340
  19.    Begin CommandButton CancelButton 
  20.       Caption         =   "&Cancel"
  21.       Height          =   390
  22.       Left            =   3240
  23.       TabIndex        =   4
  24.       Top             =   4320
  25.       Width           =   1170
  26.    End
  27.    Begin CommandButton PrintButton 
  28.       Caption         =   "&Print"
  29.       Height          =   390
  30.       Left            =   600
  31.       TabIndex        =   3
  32.       Top             =   4320
  33.       Visible         =   0   'False
  34.       Width           =   1170
  35.    End
  36.    Begin CheckBox TextOnly 
  37.       Caption         =   "Text Only"
  38.       FontBold        =   -1  'True
  39.       FontItalic      =   0   'False
  40.       FontName        =   "MS Sans Serif"
  41.       FontSize        =   12
  42.       FontStrikethru  =   0   'False
  43.       FontUnderline   =   0   'False
  44.       Height          =   375
  45.       Left            =   1080
  46.       TabIndex        =   8
  47.       Top             =   3480
  48.       Width           =   3015
  49.    End
  50.    Begin CheckBox PromptBeforePrint 
  51.       Caption         =   "Prompt Before Printing"
  52.       FontBold        =   -1  'True
  53.       FontItalic      =   0   'False
  54.       FontName        =   "MS Sans Serif"
  55.       FontSize        =   12
  56.       FontStrikethru  =   0   'False
  57.       FontUnderline   =   0   'False
  58.       Height          =   390
  59.       Left            =   1080
  60.       TabIndex        =   5
  61.       Top             =   3000
  62.       Value           =   1  'Checked
  63.       Width           =   2985
  64.    End
  65.    Begin Label Message 
  66.       BackColor       =   &H00FFFF00&
  67.       FontBold        =   -1  'True
  68.       FontItalic      =   0   'False
  69.       FontName        =   "MS Sans Serif"
  70.       FontSize        =   9.75
  71.       FontStrikethru  =   0   'False
  72.       FontUnderline   =   0   'False
  73.       Height          =   300
  74.       Left            =   600
  75.       TabIndex        =   6
  76.       Top             =   3960
  77.       Width           =   3855
  78.    End
  79.    Begin Label Explination 
  80.       Caption         =   " To Print the clipboard just PASTE something to the clipboard and then DOUBLE-CLICK the ICON "
  81.       Height          =   588
  82.       Index           =   2
  83.       Left            =   96
  84.       TabIndex        =   2
  85.       Top             =   2400
  86.       Width           =   5004
  87.    End
  88.    Begin Label Explination 
  89.       Caption         =   "To print the clipboard without first being prompted just turn off the 'Prompt before Print' checkbox.  IF you then want to return to this configuration screen just 'Double click' the ICON with NOTHING in the Clipboard.  "
  90.       Height          =   972
  91.       Index           =   1
  92.       Left            =   96
  93.       TabIndex        =   1
  94.       Top             =   1248
  95.       Width           =   5004
  96.    End
  97.    Begin Label Explination 
  98.       Caption         =   "   1)TEXT  2)BITMAP  3)D.I.B."
  99.       Height          =   300
  100.       Index           =   3
  101.       Left            =   96
  102.       TabIndex        =   7
  103.       Top             =   768
  104.       Width           =   5004
  105.    End
  106.    Begin Label Explination 
  107.       Caption         =   "This utility will print the contents of the Windows clipboard.  It can print Three types of data from the clipboard: "
  108.       Height          =   588
  109.       Index           =   0
  110.       Left            =   96
  111.       TabIndex        =   0
  112.       Top             =   96
  113.       Width           =   5004
  114.    End
  115. Sub CancelButton_Click ()
  116. PrintCB.Windowstate = WS_MINIMIZED
  117. End Sub
  118. Sub Form_Load ()
  119. PrintCB.Windowstate = WS_MINIMIZED
  120. OKtoPrint = False
  121. End Sub
  122. Sub Form_Resize ()
  123. Dim TextToPrint$
  124. If PrintCB.Windowstate = WS_NORMAL Then
  125.   If PrintCB.PromptBeforePrint.value = False Then
  126.     rc = Printit()
  127.     If rc = 0 Then
  128.       PrintCB.Windowstate = WS_MINIMIZED
  129.     End If
  130.   Else
  131.     CBType = GetClipboardType()
  132.     If CBType Then
  133.       PrintCB.PrintButton.visible = True
  134.       PrintCB.Message.caption = " OK to Print: " + TypeDescription + "?"
  135.     Else
  136.       PrintCB.PrintButton.visible = False
  137.       PrintCB.Message.caption = " No valid data in Clipboard!"
  138.     End If
  139.   End If
  140. End If
  141. End Sub
  142. Function GetClipboardType () As Integer
  143. If Clipboard.GetFormat(CF_DIB) And TextOnly.value = False Then
  144.   GetClipboardType = CF_DIB
  145.   TypeDescription = "D.I.B"
  146. ElseIf Clipboard.GetFormat(CF_BITMAP) And TextOnly.value = False Then
  147.   GetClipboardType = CF_BITMAP
  148.   TypeDescription = "Bitmap"
  149. ElseIf Clipboard.GetFormat(CF_TEXT) Then
  150.   GetClipboardType = CF_TEXT
  151.   TypeDescription = "Text"
  152.   GetClipboardType = 0
  153. End If
  154. End Function
  155. Sub PrintButton_Click ()
  156. a = b
  157. rc = Printit()
  158. End Sub
  159. Function Printit () As Integer
  160. '0 = OK
  161. '1 = Error
  162. Printit = 0
  163. On Error GoTo Printit_Error
  164. CBType = GetClipboardType()
  165. Select Case CBType
  166.   Case CF_TEXT
  167.     TextToPrint$ = Clipboard.GetText(CF_TEXT)
  168.     Printer.Print TextToPrint$
  169.     Printer.EndDoc
  170.     PrintCB.Windowstate = WS_MINIMIZED
  171.   Case CF_BITMAP
  172.     PrintPIC.Show
  173.     PrintPIC.Windowstate = WS_MAXIMIZED
  174.     PrintPIC.Picture = Clipboard.GetData(CF_BITMAP)
  175.     PrintPIC.PrintForm
  176.     Printer.EndDoc
  177.     Unload PrintPIC
  178.     PrintCB.Windowstate = WS_MINIMIZED
  179.   Case CF_DIB
  180.     PrintPIC.Windowstate = WS_MAXIMIZED
  181.     PrintPIC.Picture = Clipboard.GetData(CF_DIB)
  182.     PrintPIC.PrintForm
  183.     Printer.EndDoc
  184.     Unload PrintPIC
  185.     PrintCB.Windowstate = WS_MINIMIZED
  186.   Case Else
  187.     Printit = 1
  188.     PrintCB.Message.caption = "No valid data in clipboard"
  189.     PrintCB.PrintButton.visible = False
  190. End Select
  191. Exit Function
  192. Printit_Error:
  193. Debug.Print Str$(Err), Error$(Err)
  194. Printit = 1
  195. PrintCB.Message.caption = "An Error occured during print"
  196. PrintCB.PrintButton.visible = False
  197. Exit Function
  198. End Function
  199.